import less from 'less';

// 切换主题
export const changeTheme = (themeOption: Record<string, string>) => {
  less
    .modifyVars({
      // 调用 `less.modifyVars` 方法来改变变量值
      ...themeOption,
    })
    .then(() => {
      console.log('修改成功');
    });
};

// 修改css变量

export const setCssVar = (themeOption: { [x: string]: any }) => {
  const root = document.querySelector(':root') as HTMLScriptElement;
  Object.keys(themeOption).forEach((key) => {
    root.style.setProperty(key, themeOption[key]);
  });
};
